<?php require_once('Connections/hitekforyou.php'); ?>
<?php
// Load the common classes
require_once('includes/common/KT_common.php');

// Load the tNG classes
require_once('includes/tng/tNG.inc.php');

// Make a transaction dispatcher instance
$tNGs = new tNG_dispatcher("");

// Make unified connection variable
$conn_hitekforyou = new KT_connection($hitekforyou, $database_hitekforyou);

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$maxRows_sanpham = 12;
$pageNum_sanpham = 0;
if (isset($_GET['pageNum_sanpham'])) {
  $pageNum_sanpham = $_GET['pageNum_sanpham'];
}
$startRow_sanpham = $pageNum_sanpham * $maxRows_sanpham;

mysql_select_db($database_hitekforyou, $hitekforyou);
$query_sanpham = "SELECT * FROM sanpham WHERE AnHien = 1 ORDER BY idSP DESC";
$query_limit_sanpham = sprintf("%s LIMIT %d, %d", $query_sanpham, $startRow_sanpham, $maxRows_sanpham);
$sanpham = mysql_query($query_limit_sanpham, $hitekforyou) or die(mysql_error());
$row_sanpham = mysql_fetch_assoc($sanpham);

if (isset($_GET['totalRows_sanpham'])) {
  $totalRows_sanpham = $_GET['totalRows_sanpham'];
} else {
  $all_sanpham = mysql_query($query_sanpham);
  $totalRows_sanpham = mysql_num_rows($all_sanpham);
}
$totalPages_sanpham = ceil($totalRows_sanpham/$maxRows_sanpham)-1;


$queryString_sanpham = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_sanpham") == false && 
        stristr($param, "totalRows_sanpham") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_sanpham = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_sanpham = sprintf("&totalRows_sanpham=%d%s", $totalRows_sanpham, $queryString_sanpham);

// Make a logout transaction instance
$logoutTransaction = new tNG_logoutTransaction($conn_hitekforyou);
$tNGs->addTransaction($logoutTransaction);
// Register triggers
$logoutTransaction->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "thoat");
$logoutTransaction->registerTrigger("END", "Trigger_Default_Redirect", 99, "Index.php");
// Add columns
// End of logout transaction instance

// Make a login transaction instance
$loginTransaction = new tNG_login($conn_hitekforyou);
$tNGs->addTransaction($loginTransaction);
// Register triggers
$loginTransaction->registerTrigger("STARTER", "Trigger_Default_Starter", 1, "POST", "dangnhap");
$loginTransaction->registerTrigger("END", "Trigger_Default_Redirect", 99, "{kt_login_redirect}");
// Add columns
$loginTransaction->addColumn("kt_login_user", "STRING_TYPE", "POST", "user_name");
$loginTransaction->addColumn("kt_login_password", "STRING_TYPE", "POST", "user_pass");
// End of login transaction instance

// Execute all the registered transactions
$tNGs->executeTransactions();

// Get the transaction recordset
$rscustom = $tNGs->getRecordset("custom");
$row_rscustom = mysql_fetch_assoc($rscustom);
$totalRows_rscustom = mysql_num_rows($rscustom);


$TFM_LimitLinksEndCount = 12;
$TFM_temp = $pageNum_sanpham + 1;
$TFM_startLink = max(1,$TFM_temp - intval($TFM_LimitLinksEndCount/2));
$TFM_temp = $TFM_startLink + $TFM_LimitLinksEndCount - 1;
$TFM_endLink = min($TFM_temp, $totalPages_sanpham + 1);
if($TFM_endLink != $TFM_temp) $TFM_startLink = max(1,$TFM_endLink - $TFM_LimitLinksEndCount + 1);


?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Trang chủ</title>
<link href="css.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" src="stmenu.js"></script>
<script src="AC_RunActiveContent.js" type="text/javascript"></script>
<link href="includes/skins/mxkollection3.css" rel="stylesheet" type="text/css" media="all" />
<script src="includes/common/js/base.js" type="text/javascript"></script>
<script src="includes/common/js/utility.js" type="text/javascript"></script>
<script src="includes/skins/style.js" type="text/javascript"></script>
<style type="text/css">
<!--
.style1 {
	color: #FF0000;
	font-weight: bold;
	font-style: italic;
}
-->
</style>
</head>

<body>
<div id="container">
  <div id="header">
   <?php include("banner.php"); ?> 
  </div>
  <div id="menu">
   <script type="text/javascript" src="menu.js"></script>

  </div>
  <div id="main">
    <!-- Start Div Left Main -->
    <?php include("leftmain.php"); ?>
        <!-- End Div Left Main -->
    <!-- Start Div right Main -->
   <div id="rightmain">


    <?php
//Show If User Is Logged In (region1)
$isLoggedIn = new tNG_UserLoggedIn($conn_hitekforyou);
//Grand Levels: Level
if ($isLoggedIn->Execute()) {
?>
<form id="DangXuat" name="dangxuat" method="post" action="">
          <table width="184" border="0" cellspacing="0" cellpadding="0" align="center">
            <tbody>
              <tr>
                <td align="center"><img src="images/dang-nhap.jpg" alt="6" width="184" height="41" /></td>
              </tr>
              <tr>
                <td height="170" valign="top" background="images/dang-nhap-bg.jpg" style="padding:5px 5px 5px 5px; background-repeat:no-repeat;"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tbody>
                      <tr>
                        <td valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
                            <tbody>
                              <tr>
                                <td><div align="center"><strong>Chào
                                    <?php echo $_SESSION['kt_TenKH']; ?> </strong></div></td>
                              </tr>
                              <tr>
                                <td height="8"><img src="images/spacer.gif" alt="5" width="1" height="1" /></td>
                              </tr>
                              <tr>
                                <td><div align="center"><strong><a href="doithongtincanhan.php" class="lienket">Đổi thông tin cá nhân</a></strong></div></td>
                              </tr>
                              <tr>
                                <td height="5"><img  src="images/spacer.gif" alt="4" width="1" height="1" /></td>
                              </tr>
                              <tr>
                                <td><div align="center">
                                  </div></td>
                              </tr>
                              <tr>
                                <td height="5"><img src="images/spacer.gif" alt="3" width="1" height="1" /></td>
                              </tr>
                              <tr>
                                <td>&nbsp;</td>
                              </tr>
                              <tr>
                                <td height="5"><img  src="images/spacer.gif" alt="2" width="1" height="1" /></td>
                              </tr>
                              <tr>
                                <td height="5" align="center"><?php
	echo $tNGs->getErrorMsg();
?><input type="submit" name="thoat" id="button2" value="Thoát" onclick="funABC()" /></td>
                              </tr>
                              <tr>
                                <td height="5"><img src="images/spacer.gif" alt="1" width="1" height="1" /></td>
                              </tr>
                            </tbody>
                        </table></td>
                      </tr>
                      <tr>
                        <td valign="top"><label>
                            <div align="center"></div>
                          </label></td>
                      </tr>
                    </tbody>
                  </table>
                    <label>
                    <div align="center"></div>
                  </label></td>
              </tr>
            </tbody>
          </table>
            </form>


      <?php 
// else Show If User Is Logged In (region1)
} else { ?>
      <form id="DangNhap" name="DangNhap" method="post" action="">
          <table width="184" border="0" cellspacing="0" cellpadding="0" align="center">
            <tbody>
              <tr>
                <td align="center"><img src="images/dang-nhap.jpg" width="184" height="41" /></td>
              </tr>
              <tr>
                <td height="170" valign="top" background="images/dang-nhap-bg.jpg" style="padding:5px 5px 5px 5px; background-repeat:no-repeat;"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                    <tbody>
                      <tr>
                        <td valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0">
                            <tbody>
                              <tr>
                                <td><div align="center"><strong>Tên đăng nhập</strong></div></td>
                              </tr>
                              <tr>
                                <td height="8"><img src="images/spacer.gif" width="1" height="1" /></td>
                              </tr>
                              <tr>
                                <td><div align="center">
                                  <input type="text" name="user_name" id="user_name" />
                                </div></td>
                              </tr>
                              <tr>
                                <td height="5"><img src="images/spacer.gif" width="1" height="1" /></td>
                              </tr>
                              <tr>
                                <td><div align="center"><strong>Mật khẩu</strong></div></td>
                              </tr>
                              <tr>
                                <td height="5"><img src="images/spacer.gif" width="1" height="1" /></td>
                              </tr>
                              <tr>
                                <td><div align="center">
                                  <input type="password" name="user_pass" id="user_pass" />
                                </div></td>
                              </tr>
                              <tr>
                                <td height="5"><img src="images/spacer.gif" width="1" height="1" /></td>
                              </tr>
                              <tr>
                                <td height="5" align="center"><input type="submit" name="dangnhap" id="button" value="Đăng nhập" /></td>
                              </tr>
                              <tr>
                                <td height="5"><img src="images/spacer.gif" width="1" height="1" /></td>
                              </tr>
                            </tbody>
                        </table></td>
                      </tr>
                    </tbody>
                  </table>
                    <label>
                    <div align="center"></div>
                  </label></td>
              </tr>
            </tbody>
          </table>
        </form> <!-- End Form Đăng nhập -->
  <?php
}
//End Show If User Is Logged In (region1)
?>


        
      <table width="184" border="0" cellspacing="0" cellpadding="0" align="center">
        <tbody>
          <tr>
            <td align="center"><img src="images/tin-moi-nhat.jpg" width="184" height="40" /></td>
          </tr>
          <tr>
            <td height="226" valign="top" background="images/tin-moi-nhat-bg.jpg" style="padding:5px 5px 5px 5px; background-repeat:no-repeat;"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tbody>
                  <tr>
                    <td>
<div style="height:200px;">
<marquee behavior="scroll" direction="up" height="200px" scrolldelay="700">
<div style="padding-bottom:2px; padding-top:5px;padding-left:5px;"><img src="images/arrow2.gif" width="9" height="7" />Tin mới</div>
</marquee>
</div></td>
                  </tr>
                </tbody>
            </table></td>
          </tr>
        </tbody>
      </table> <!-- End Table Tin tuc -->
    </div>
        <!-- End Div right Main -->
    <div id="content">
    <table width="600" border="0" align="center" cellpadding="0" cellspacing="0" id="main1">
        <tr>
          <td><table width="100%" border="0" cellpadding="0" cellspacing="0" id="IPad">
              <tbody>
                <tr>
                  <td valign="top" bgcolor="#FFFFFF"><div>
                      <table width="600" border="0" align="center" cellpadding="0" cellspacing="0" id="main2">
                        <tr>
                          <td><table width="100%" border="0" cellpadding="0" cellspacing="0" id="IPad2">
                              <tbody>
                                <tr>
                                  <td width="9"><img src="images/bc-t-l.gif" width="9" height="9" /></td>
                                  <td bgcolor="#FFFFFF"><img src="Apple IPad files/spacer.gif" width="1" height="1" /></td>
                                  <td width="11"><img src="images/bc-t-r.gif" width="11" height="9" /></td>
                                </tr>
                                <tr>
                                  <td bgcolor="#FFFFFF"><img src="Apple IPad files/spacer.gif" width="1" height="1" /></td>
                                  <td align="left" valign="top" bgcolor="#FFFFFF"><div class="tieude1">
                                      <p>CHÍNH SÁCH BẢO HÀNH</p>
                                  </div>
                                      <div class="style3">
                                        <p><br />
                                        </p>
                                      </div>
                                    <div class="style1"> 1. Điều kiện được bảo hành</div>
                                    <br />
                                      <div> . Có phiếu bảo hành của HitekForYou &amp; tem bảo hành của nhà sản xuất trên sản phẩm</div>
                                      <br />
                                      <div> ·  Tem bảo hành của nhà sản xuất / nhà phân phối &amp; tem bảo hành của   điện thoại phải còn nguyên vẹn.</div>
                                    <br />
                                      <div> ·  Sản phẩm còn trong thời hạn bảo hành. (Được ghi rõ trên phiếu bảo hành)</div>
                                    <br />
                                      <div> ·  Sản phẩm đủ điều kiện bảo hành theo điều kiện bảo hành của  HitekForYou và theo quy định của từng hãng sản xuất.(sẽ được gửi kèm   khi khách hàng  mua sản phẩm từ công ty)</div>
                                    <br />
                                      <div class="style1"> 2. Các điều khoản từ chối bảo hành: </div>
                                    <br />
                                      <div> ·   Thiết bị hết thời hạn bảo hành</div>
                                    <br />
                                      <div> ·    Máy tiếp xúc với chất lỏng hoặc đổ chất lỏng vào máy hoặc được bảo         quản/sử dụng trong môi trường ẩm ướt. </div>
                                    <br />
                                      <div>·   Sử dụng sai quy định của nhà sản xuất. </div>
                                    <br />
                                      <div>·   Tem bảo hành bị rách, bị sửa chữa, hoặc bị dán đè tem khác.</div>
                                    <br />
                                      <div>·   Các lỗi về phần mềm chỉ được hỗ trợ khắc phục, không thuộc phạm vi BH </div>
                                    <br />
                                      <div class="style3"></div>
                                    <div></div></td>
                                  <td bgcolor="#FFFFFF"><img src="Apple IPad files/spacer.gif" width="1" height="1" /></td>
                                </tr>
                                <tr>
                                  <td><img src="images/bc-u-l.gif" width="9" height="11" /></td>
                                  <td bgcolor="#FFFFFF"><img src="Apple IPad files/spacer.gif" width="1" height="1" /></td>
                                  <td><img src="images/bc-u-r.gif" width="11" height="11" /></td>
                                </tr>
                              </tbody>
                          </table></td>
                        </tr>
                      </table>
                  </div></td>
                </tr>
              </tbody>
          </table></td>
        </tr>
      </table>
    </div> 
    <!-- End div content -->
  </div><!-- End div Main -->
  <div id="footer">
  <?php include("footer.php"); ?>
  </div>
</div>
</body>
</html>
<?php
mysql_free_result($sanpham);
?>
